<template>
    <div :style="{ height: tableY + 75 + 'px'}" style="margin-bottom: 40px;">
      <div class="margin-bottom-xs">
        <a-button
            type="danger"
            icon="delete"
            @click="handleSub($refs.table.selectedRowKeys)"
            v-action:SuperAdministratorDelete
        >
          {{$ct("delete","删除")}}
        </a-button>
        <a-button class="cu-btn-danger" type="link" @click="() => $emit('clearAll')" v-action:SuperAdministratorAllClear>一键清空</a-button>
      </div>
      <!--	table	 -->
      <DataGrid
          ref="table"
          :columns="columns"
          :url="url"
          :queryParam="queryParam"
          rowKey="uuid"
          :format-conditions="true"
          :pageSize="500"
          :scroll="{
                y:tableY
            }"
      >
          <span slot="renderUserNameId" slot-scope="{ text, record, index }">
                      {{ record.userName }}/{{  record.userNameId }}
          </span>
        <template slot="renderLogBrowser" slot-scope="{ text, record, index }">
          <a-tooltip>
            <template slot="title">
              {{text}}
            </template>
            {{text}}
          </a-tooltip>
        </template>
      </DataGrid>
    </div>
  </template>
  
  <!--script-->
  <script>
  
  //数据表格组件
  import {DataGrid} from "@/components";
  //方法封装
  import {dataGridMixin} from "@/mixins/dataGridMixin";
  
  export default {
    name: "Table",
    components: {DataGrid},
    mixins: [dataGridMixin],
    filters: {},
    props: {
      tableY: 0,
      queryParam: {
        type: Object,
        defaultValue: () => {
          return {
            operationType: 'requestLog.01'
          }
        }
      },// 查询参数
    },
    data() {
      return {
        columns: [
          {
            title: '登录时间',
            width: 170,
            dataIndex: 'createTime',
            langCode: "loginTime"
          },
          {
            title: '登录账号',
            width: 200,
            dataIndex: 'userNameId',
            langCode: "loginAccount",
            scopedSlots: {
              customRender: 'renderUserNameId'
            }
          },
          {
            title: '登录IP',
            width: 120,
            dataIndex: 'logIp',
            langCode: "loginIp"
          },
          {
            title: '登录设备',
            dataIndex: 'logBrowser',
            langCode: "loginDevice",
            scopedSlots: {
              customRender: "renderLogBrowser"
            }
          }
        ],
        visible: false,
        confirmLoading: false,
        mdl: null,
  
        url: {
          getPageSet: '/system/sysLoginLog/getPageSet',
          deleteBatch: '/system/sysLoginLog/deleteBatch'
        },
        startTime: ''
      };
    },
    mounted() {
    },
    methods: {
  
      startTimeOnChange(val) {
        this.queryParam.startTime = val.join(',')
      }
    },
  };
  </script>
  
  <!--style-->
  <style scoped lang="less">
  .table {
    background-color: @base-bg-color;
    padding: 24px;
  }
  </style>
  